﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JustMoveIt.Logic;

namespace JustMoveIt
{
    public partial class MainForm : Form
    {
       

        public MainForm()
        {
            InitializeComponent();
            
            PostInit();
        }
        
        private void PostInit()
        {
            _srcPathTextBox.Text = Settings.Instance.Source;
            _destPathTextBox.Text = Settings.Instance.Dest;
            registryCheck.Checked = Settings.Instance.Registry;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void BrowseSrcClick(object sender, EventArgs e)
        {
            _folderBrowserDialog1.ShowDialog(this);
            string srcPath = _folderBrowserDialog1.SelectedPath;
            if (Directory.Exists(srcPath))
            {
                _srcPathTextBox.Text = srcPath;
            }
            
        }

        private void _justMoveIt_Click(object sender, EventArgs e)
        {
            JustMoveItLogic.Instance.JustMoveIt(new DirectoryInfo(_srcPathTextBox.Text), new DirectoryInfo(_destPathTextBox.Text));
        }

        private void _browseDest_Click(object sender, EventArgs e)
        {
            _folderBrowserDialog1.ShowDialog(this);
            string destPath = _folderBrowserDialog1.SelectedPath;
            if (Directory.Exists(destPath))
            {
                _destPathTextBox.Text = destPath;
            }
        }

        private void _reloadButton_Click(object sender, EventArgs e)
        {
            JustMoveItLogic.Instance.LoadExtData();
        }

        private void registryCheck_CheckedChanged(object sender, EventArgs e)
        {
            
            bool check = registryCheck.Checked;
            if (check)
            {
                RegistryHelper.CreateRegistry(Application.ExecutablePath);
                Settings.Instance.Registry = true;
            }
            else
            {
                RegistryHelper.RemoveRegistry();
                Settings.Instance.Registry = false;
            }
        }

    }
}
